package leetcode.D200.T141;

import util.ListNode;
import util.ListUtil;

public class E141 {
    public static void main(String[] args) {
        String data = "[]";
        int pos = -1;
        ListNode head = ListUtil.parseListNode(data);
        ListUtil.printListNode(head);
        cyclic(head, pos);
        System.out.println(new Solution().hasCycle(head));
        /*for (int i = 0; i < 10; i++) {
            if(head == null) break;
            System.out.print(head.val + "->");
            head = head.next;
        }*/
    }
    private static void cyclic(ListNode head, int pos) {
        if(pos < 0) return;
        int i = 0;
        ListNode p = head;
        while(i < pos) {
            p = p.next;
            i++;
        }
        ListNode tail = p;
        while(tail.next != null) {
            tail = tail.next;
        }
        tail.next = p;
    }
}
